﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//
using System.IO;
using System.Management;
using System.Management.Instrumentation;

namespace Flac2Wma
{
    public sealed class InstalledApp
    {
#if false
        public static bool isInstalled()
        {
            ConnectionOptions conn = new ConnectionOptions();
            ManagementScope scope = new ManagementScope(@"\\.\root\CIMV2", conn);
            ManagementObjectSearcher mos = new ManagementObjectSearcher(scope,new ObjectQuery("SELECT Name, Vendor, Version FROM Win32_Product"));
            foreach (ManagementObject mo in mos.Get())
            {
                if (mo["Name"] != null)
                {
                    if (mo["Name"].ToString().StartsWith("Microsoft Expression Encoder", StringComparison.CurrentCultureIgnoreCase))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
#else
        public static bool isInstalled()// szybszy!
        {
            return
                File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\Microsoft Expression\Encoder 4\Encoder.exe")
                ||
            File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\Microsoft Expression\Encoder 4\Encoder.exe");
        }
#endif
    }//class
}//namespace
